package com.catsic.zcjc.dao;

import java.util.List;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import com.catsic.base.BaseDao;
import com.catsic.zcjc.entity.Equip;
import com.catsic.zcjc.entity.Station;


public interface EquipDao extends BaseDao<Equip, String>{
	

	@Query("select e from Equip e where e.station.id in(select s.id from Station s where s.organ.id = ?1) order by e.code asc")
	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
	public List<Equip> findByOid(String oid);
	

	@Query("select e from Equip e where e.station.id = ?1 order by e.code asc")
	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
	public List<Equip> findByStationId(String stationId);
	
	@Query("select e from Equip e where e.system.id = ?1 order by e.code asc")
	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
	public List<Equip> findBySystemId(String systemId);
	
	/**
	 * 通过级别与编码获取机构
	 * @param code
	 * @param jb
	 * @return
	 */
	public List<Equip> findByNameAndStationOrderByNameAsc(String name,Station station);
	
	public Equip findByCodeAndStation(String code,Station station);
	
	public Equip findByCode(String code);
}
